package com.example.demo.controller;

import com.example.demo.Response;
import com.example.demo.dto.OutfitDTO;
import com.example.demo.service.OutfitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@RestController
public class OutfitController {
    @Autowired
    OutfitService outfitService;
    @GetMapping("outfit/{userId}")
    public Response<Set<OutfitDTO>> getOutfitByUserId(@PathVariable long userId)
    {
        return Response.newSuccess(outfitService.getOutfitByUserId(userId));
    }
    @GetMapping("outfit/{userId}/name/{name}")
    public Response<OutfitDTO> getOutfitByUserIdAndName(@PathVariable long userId, @PathVariable String name)
    {
        return Response.newSuccess(outfitService.getOutfitByUserIdAndName(userId, name));
    }
    @GetMapping("outfit/{userId}/category/{category}")
    public Response<Set<OutfitDTO>> getOutfitByUserIdAndCategory(@PathVariable long userId, @PathVariable String category)
    {
        return Response.newSuccess(outfitService.getOutfitByUserIdAndCategory(userId, category));
    }
    @PostMapping("outfit/{userId}")
    public Response<Long> addOutfitByUserId(@PathVariable long userId, @RequestBody OutfitDTO outfitDTO)
    {
        return Response.newSuccess(outfitService.addOutfitByUserId(outfitDTO,userId));
    }
    @DeleteMapping("outfit/{userId}/{name}")
    public void deleteOutfitByUserIdAndName(@PathVariable long userId, @PathVariable String name){
        outfitService.deleteOutfitByUserIdAndName(userId, name);
    }
    @PutMapping("outfit/{userId}/{name}")
    public Response<OutfitDTO> updateOutfitByUserIdAndName(@PathVariable long userId, @PathVariable String name, @RequestParam String description)
    {
        return Response.newSuccess(outfitService.updateOutfitByUserIdAndName(userId, name, description));
    }
    @PostMapping("outfit/userId/{userId}/clothId/{userClothId}/name/{name}")
    public Response<Long> addClothToOutfitByUserIdAndUserClothIdAndName(@PathVariable String name, @PathVariable int userClothId, @PathVariable long userId){
        return Response.newSuccess(outfitService.addClothToOutfitByUserIdAndUserClothIdAndName(name, userClothId, userId));
    }
//    @PostMapping("outfit/userId/{userId}/name/{name}")
//    public Response<Long> addClothToOutfitByUserIdAndName(@PathVariable long userId, @PathVariable String name,@RequestBody ClothDTO clothDTO){
//        return Response.newSuccess(outfitService.addClothToOutfitByUserIdAndName(name, userId, clothDTO));
//    }
}
